package cool.taomu.web.controller;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

import com.google.gson.Gson;

import cool.taomu.utils.GuavaCache;
import cool.taomu.utils.inter.IStorage;
import cool.taomu.web.core.Type;
import cool.taomu.web.entity.Message;
import cool.taomu.web.entity.echarts.Option;
import cool.taomu.web.utils.StockDataUtils;

@SuppressWarnings("unchecked")
public class WebSocketConteroller {
	
	static {
		StockDataUtils.getInstance().getH2();
		ExecutorService es = Executors.newFixedThreadPool(2);
		//Subscriber sub = new Subscriber("c222.taomu.cool",1883,"","");
		//sub.subscriber(es, JvmInfoMqttCallback.class);
	}
	IStorage is = GuavaCache.getInstance();
	
	@Type("monitor")
	public String monitor(String message) {
		return new Gson().toJson(is.get("taomu/jvm/info", "jvminfo"));
	}

	@Type("run")
	public String codeRun(String message) {
		Message msg = new Message();
		msg.setType("0");
		msg.setData(new Option());
		String a = new Gson().toJson(msg);
		return a;
	}
	
	@Type("stockList")
	public String s(String message) {
		return new StockDataController().getStockIndustryList(message);
	}
}
